<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../Template/AdminTemplate.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content">
        <h:form id="form">
            <p:panel header="Faq Manager" id="panel1" style="font-size: 12px;">
                            <h:commandLink style="font-size: 11px;">  
                                <p:graphicImage value="../images/icons/excel.png" />  
                                <p:dataExporter type="xls" target="data" fileName="faq"/>  
                            </h:commandLink>
                            <p:separator />
                            <p:commandButton actionListener="#{faqControl.goInsert()}" icon="ui-icon-disk" value="Insert" style="margin-top: 5px;margin-left: 620px;font-size: 11px;" />
                            <p:dataTable value="#{faqControl.findAll()}" var="item" id="data" paginator="true" rows="15"
                                         rowsPerPageTemplate="5,10,15">
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Faqid" />
                                    </f:facet>
                                    <h:outputText value="#{item.faqId}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Question"/>
                                    </f:facet>
                                    <h:outputText value="#{item.asking}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Answer"/>
                                    </f:facet>
                                    <h:outputText value="#{item.answering}"/>
                                </p:column>
                                <p:column style="width:40px">  
                                    <p:commandButton id="selectButton" update=":form:display"  oncomplete="carDialog.show()" icon="ui-icon-search" title="View">  
                                        <f:setPropertyActionListener value="#{item}" target="#{faqControl.selectedFaq}" />  
                                    </p:commandButton>  
                                </p:column>
                                <p:column>
                                    <p:commandButton style="font-size: 11px;" value="Update" action="#{faqControl.showdetail(item)}" icon="ui-icon-arrowrefresh-1-w"/>  
                                </p:column>
                                <p:column>
                                    <p:commandButton style="font-size: 11px;" value="Delete"  onclick="confirmation.show()" icon="ui-icon-close" >
                                        <f:setPropertyActionListener value="#{item}" target="#{faqControl.faq}" />
                                    </p:commandButton>
                                    <p:confirmDialog id="confirmDialog" message="Are you sure about delete this faq?"  
                                                     header="Initiating destroy process" severity="alert" widgetVar="confirmation">
                                        <p:commandButton id="confirm" style="font-size: 11px;" actionListener="#{faqControl.delete(item)}" value="Yes Sure" oncomplete="confirmation.hide()"/>
                                        <p:commandButton id="decline" style="font-size: 11px;" value="Not Yet" onclick="confirmation.hide()" />   
                                    </p:confirmDialog>
                                </p:column>
                            </p:dataTable>
                            <p:blockUI block="data" trigger="data">  
                                Waiting...<br />  
                                <p:graphicImage value="./../resources/images/icons/ajax-loader.gif"/>  
                            </p:blockUI>
                            <p:dialog header="FAQ Detail" widgetVar="carDialog" resizable="false" id="carDlg"  
                                      showEffect="clip" hideEffect="explode" modal="true">  
                                <h:panelGrid columns="2" id="display">
                                    <h:outputLabel value="Faqid:" for="faqid" />
                                    <h:outputText id="faqid" value="#{faqControl.selectedFaq.faqId}" title="Faqid" />
                                    <h:outputLabel value="Question:" for="question" />
                                    <h:outputText id="question" value="#{faqControl.selectedFaq.asking}" title="Question" />
                                    <h:outputLabel value="Answer:" for="answer" />
                                    <h:outputText id="answer" value="#{faqControl.selectedFaq.answering}" title="Answer" />
                                </h:panelGrid>
                            </p:dialog>
                        </p:panel>
        </h:form>
    </ui:define>

</ui:composition>
